<?php

	class xl_sanpham extends database

	{
		//san pham co ma loai trang la 16
		function Load_SanPhamTheoMa($matintuc)
		{
			$sql = "Select * from tintuc where matintuc = '".$matintuc."' and maloaitrang='16'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}
		function LoadAll_SanPham()
		{
			$sql = "Select * from tintuc where maloaitrang = '16'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}

		function Load_SanPham($start, $display)
		{
			$sql = "Select * from tintuc where maloaitrang = '16' ORDER BY (ngaydang) DESC LIMIT $start, $display";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function DemTrangSanPham()

		{
			$sql = "Select COUNT(matintuc) as tong from tintuc where maloaitrang = '16'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}
		
		

		

		function them_sanpham($txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$hinhanh,$ngaydang,$manguoi,$mota)

		{

			$sql = "INSERT INTO tintuc (maloaitrang,tieude,noidungthugon,noidungdaydu,tags,hinhanh,ngaydang,manguoidung,mota) VALUES ('16','".$txtTieuDe."','".$noidungthugon."','".$noidungdaydu."','".$tukhoa."','".$hinhanh."','".$ngaydang."','".$manguoi."','".$mota."')";

			$this->setQuery($sql);

			return $this->query();

			//return $sql;

			

		}

		

		function them_sanpham1($txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$ngaydang,$manguoi,$mota)

		{

			$sql = "INSERT INTO tintuc (maloaitrang,tieude,noidungthugon,noidungdaydu,tags,ngaydang,manguoidung,mota) VALUES ('16','".$txtTieuDe."','".$noidungthugon."','".$noidungdaydu."','".$tukhoa."','".$ngaydang."','".$manguoi."','".$mota."')";

			$this->setQuery($sql);

			return $this->query();

			//return $sql;

			

		}

		//Phuong - ADD - END - 02/03/2012

		

		function xoa_sanpham($id)

		{

			$sql ="delete from tintuc where matintuc = '".$id."'";

			$this->setQuery($sql);

			return $this->query();

		}
		
		
		function Load_All_SanPham()
		{
			$sql = "Select * from tintuc where maloaitrang = '16' ORDER BY (ngaydang) DESC ";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_All_SanPham_Limit($start, $display)
		{
			$sql = "Select * from tintuc where maloaitrang = '16' ORDER BY (ngaydang) DESC LIMIT $start, $display";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function capnhatsanpham($matt,$txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$hinhanh,$manguoi,$mota)

		{

			$sql = "UPDATE tintuc set tieude ='".$txtTieuDe."', noidungthugon ='".$noidungthugon."',noidungdaydu='".$noidungdaydu."',hinhanh='".$hinhanh."',tags='".$tukhoa."',manguoidung='".$manguoi."',mota='".$mota."' where matintuc =".$matt;

			$this->setQuery($sql);

			return $this->query(); 

			

		}

		function capnhatsanpham1($matt,$txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$manguoi,$mota)

		{

			$sql = "UPDATE tintuc set tieude ='".$txtTieuDe."', noidungthugon ='".$noidungthugon."',noidungdaydu='".$noidungdaydu."',tags='".$tukhoa."',manguoidung='".$manguoi."',mota='".$mota."' where matintuc =".$matt;

			$this->setQuery($sql);

			return $this->query(); 

			

		}

	}

?>